<?php
include 'JHeader.php';

/**
 * Funktion, um das Admin-Menü anzuzeigen.
 *
 * @author Timo
 */
    function ShowAdminMenu($page)
    {
        echo '<table>';
        echo '<tr id="row_one">';
        if($page == 'new_league')
        {
            echo '<td class="menu_active">';
        }
        else
        {
            echo '<td class="menu">';
        }
        echo '<a href="index.php?page=new_league">Neue Liga</a></td>';

        if($page == 'all_leagues')
        {
            echo '<td class="menu_active">';
        }
        else
        {
            echo '<td class="menu">';
        }
        echo '<a href="index.php?page=all_leagues">Alle Ligen</a></td>';

        if($page == 'admins')
        {
            echo '<td class="menu_active">';
        }
        else
        {
            echo '<td class="menu">';
        }
        echo '<a href="index.php?page=admins">Admins</a></td>';

        echo '</tr>';
        //--------------------------------------------------------------------------------------------------
        echo '<tr id="row_two">';
        if($page == 'new_series')
        {
            echo '<td class="menu_active">';
        }
        else
        {
            echo '<td class="menu">';
        }
        echo '<a href="index.php?page=new_series">Neue Serie</a></td>';

        if($page == 'all_series')
        {
            echo '<td class="menu_active">';
        }
        else
        {
            echo '<td class="menu">';
        }
        echo '<a href="index.php?page=all_series">Alle Serien</a></td>';

        echo '</tr>';
        echo '</table>';
    }

    function ShowAdminContent($page)
    {
        switch($page)
        {   
            case 'new_league': include 'new_league.php';
                                break;

            case 'new_series': include 'new_series.php';
                                break;
                            
            case 'all_series': include 'all_series.php';
                                break;
            
            case 'all_leagues': include 'all_leagues.php';
                                break;
                            
            case 'admins': include 'admins.php';
                                break;
                            
            default: echo 'Page "' . $page . '" not found.';
                        break;
        }
    }

    function ShowTitel($page)
    {
        switch($page)
        {
            case 'new_league': echo 'Neue Liga erstellen';
                                break;

            case 'new_series': echo 'Neue Serie erstellen';
                                break;

            case 'all_series': echo 'Alle Serien';
                                break;

            case 'all_leagues': echo 'Alle Ligen';
                                break;

            case 'admins': echo 'Admins';
                                break;

            default: echo 'Unknown Page';
                        break;
        }
    }

 /**
 * Das Template für das Admin-Interface.
 * In der css-Datei kann das Aussehen verändert werden.
 *
 * @author Timo
 */

$page = 'all_leagues';
if(isset($_GET['page']))
{
    $page = strtolower($_GET['page']);
}

?>
<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="css/default.css" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title><?php ShowTitel($page) ?> | Ranking - ALPHA</title>
    </head>
    <body>
        <div id="header">ADMIN-INTERFACE</div>
        <div id="main">
            <div id="menu">
            <?php ShowAdminMenu($page); ?>
            </div>
            <div id="content">
            <?php ShowAdminContent($page); ?>
            </div>
        </div>
        <div id="footer">[version alpha 0.9]</div>
    </body>
</html>